﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>成本导入</title>
    <link rel="stylesheet" type="text/css" href="../Content/Css/OperaMasksUI/default/om-all.css" />
    <link rel="stylesheet" type="text/css" href="../Content/Css/list.css" />
    <script type="text/javascript" src="../Scripts/jquery.1.6.3.min.js"></script>
    <script type="text/javascript" src="../Scripts/json2.js"></script>
    <script type="text/javascript" src="../Scripts/common.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/operamasks-ui.min.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/jquery.form.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/Plugin/om-yj-container.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/jquery.artDialog.js?skin=default"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/plugins/iframeTools.js"></script>
    <script src="../Scripts/Plugin/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var detailPanel, listGrid, detailGrid, colData, detailColData, searchPanel, defaultSort, defaultWhere, validatorForm, submitForm, currentUID, currentGIndex = -1, genRenderCheckbox, genRenderDateformat;
        var showSearchPanel, showToolBar, showDetialForm, controlBtn, oldRowData, detailForm, goOn = true, DoFlag = true, ifh;

        $(document).ready(function () {
            currentUID = art.dialog.data('currentUID');
            var element = $('body').omBorderLayout({
                fit: true,
                spacing: 0,
                panels: [
                {
                    id: "center-panel",
                    header: false,
                    title: "中间模块",
                    region: "center"
                },
                {
                    id: "south-panel",
                    region: "south",
                    header: false,
                    resizable: false,
                    collapsible: false,
                    height: 50
                },
                {
                    id: "east-panel",
                    region: "east",
                    header: false,
                    resizable: false,
                    collapsible: false,
                    width:550
                }
                ]
            });
            showSearchPanel();
            colData = [
                { header: '字段名称', name: 'ColumnName', width: 50, align: 'center' },
                { header: 'EXCEL列', name: 'ExcelColumn', width: 50, align: 'center' }
            ];
            detailColData = [
                { header: '行号', name: 'Num', width: 30, align: 'left' },
                { header: '供应商编码', name: 'SupplyCode', width: 60, align: 'center' },
                { header: '供应商名称', name: 'SupplyName', width: 80, align: 'center' },
                { header: '流水号', name: 'OrderNo', width: 100, align: 'left' },
                { header: '费用项目', name: 'FeeType', width: 100, align: 'left' },
                { header: '数量', name: 'Qty', width: 60, align: 'left' },
                { header: '单价', name: 'Price', width: 60, align: 'left' },
                { header: '金额', name: 'Cost', width: 60, align: 'left' },
                { header: '支票号', name: 'CheckNo', width: 60, align: 'left' },
                { header: '导入描述', name: 'Note', width: 100, align: 'left' }
            ]
            defaultSort = { sortby: 'UID', sortdir: 'ASC' };
            defaultWhere = { where: ' 1 = 1 ' };
            listGrid = $('#listgrid').omGrid({
                width: '100%',
                singleSelect: true,
                limit: 20,
                extraData: $.extend(defaultWhere, defaultSort),
                dataSource: "../Handler/grid.ashx?view=(SELECT * FROM dbo.vImportSet WHERE TableCode = 'ZCOST' ) AS ",
                colModel: colData
            });
            detailGrid = $('#detailgrid').omGrid({
                width: '100%',
                singleSelect: true,
                limit: 20,
                extraData: $.extend({ where : ' 1=1 ' }, { sortby: 'Num', sortdir: 'ASC' }),
                dataSource: '',
                colModel: detailColData
            });
        });

        showSearchPanel = function () {
            $('#uploadify').uploadify({
                uploader: '../Handler/fileupload.ashx',
                swf: '../Scripts/Plugin/uploadify/uploadify.swf',
                cancelImage: '../Scripts/Plugin/uploadify/cancel.png',
                width: 80,
                height: 30,
                buttonClass: "btnCss",
                buttonText: "Excel",
                buttonCursor: 'hand',
                fileObjName: 'Filedata',
                fileTypeExts: "*.xls",
                fileTypeDesc: "请选择文件",
                auto: true,
                multi: false,
                queueSizeLimit: 1,
                onFallback: function () {
                    alert("您未安装FLASH控件,无法上传图片!请安装FLASH控件后再试.");
                },
                onUploadStart: function (file) {
                    $('#uploadify').uploadify('settings', 'formData', { 'userid': currentUID, 'uploadtype': 'ZCOST' });
                },
                onUploadSuccess: function (file, data, response) {
                    if (data.indexOf("ER") > -1) {
                        alert(data);
                    }
                    else {
                        alert("导入成功");
                        detailGrid.omGrid({
                            dataSource: "../Handler/grid.ashx?view=(SELECT ROW_NUMBER() OVER(ORDER BY UID ASC) AS Num,[UID],[SupplyCode],[OrderNo],[SupplyName],[FeeType],[Price],[Qty],[Cost],[CheckNo],[Note] FROM dbo.ZCOST WHERE UserCreateID = " + currentUID + " ) AS "
                        });
                    }
                }
            });

            $('#button-close').click(function () {
                art.dialog.close();
            });
        };
    </script>
</head>
<body>
    <div id="center-panel">
        <table id="listgrid"></table>
    </div>
    <div id="east-panel">
        <table id="detailgrid"></table>
    </div>
    <div id="south-panel">
        <table style="margin-top: 5px; margin-left: 20px;">
            <tr>
                <td>
                    <span id='uploadify'></span>
                </td>
                <td>
                    <input id="button-close" type="button" class="btnCss" value="关    闭" style="margin-left: 20px;" />
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
